/*     */ package com.zimbra.qa.unittest.prov.soap;
/*     */ 
/*     */ import com.zimbra.client.ZAce;
/*     */ import com.zimbra.client.ZAce.GranteeType;
/*     */ import com.zimbra.client.ZFolder;
/*     */ import com.zimbra.client.ZGrant.GranteeType;
/*     */ import com.zimbra.client.ZMailbox;
/*     */ import com.zimbra.cs.account.Account;
/*     */ import com.zimbra.cs.account.Domain;
/*     */ import com.zimbra.cs.account.Provisioning;
/*     */ import com.zimbra.cs.mailbox.ACL;
/*     */ import com.zimbra.qa.QA.Bug;
/*     */ import com.zimbra.qa.unittest.TestUtil;
/*     */ import java.util.ArrayList;
/*     */ import java.util.List;
/*     */ import org.junit.AfterClass;
/*     */ import org.junit.Assert;
/*     */ import org.junit.BeforeClass;
/*     */ import org.junit.Test;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class TestACLUserRights
/*     */   extends SoapTest
/*     */ {
/*     */   private static SoapProvTestUtil provUtil;
/*     */   private static Provisioning prov;
/*     */   private static Domain domain;
/*     */   
/*     */   @BeforeClass
/*     */   public static void init()
/*     */     throws Exception
/*     */   {
/*  45 */     provUtil = new SoapProvTestUtil();
/*  46 */     prov = provUtil.getProv();
/*  47 */     domain = provUtil.createDomain(baseDomainName());
/*     */   }
/*     */   
/*     */   @AfterClass
/*     */   public static void cleanup() throws Exception {
/*  52 */     Cleanup.deleteAll(new String[] { baseDomainName() });
/*     */   }
/*     */   
/*     */   private Account createUserAccount(String localPart) throws Exception {
/*  56 */     return provUtil.createAccount(localPart, domain);
/*     */   }
/*     */   
/*     */   @Test
/*     */   @QA.Bug(bug={42146})
/*     */   public void testFallbackToFolderRight()
/*     */     throws Exception
/*     */   {
/*  64 */     Account allowed = createUserAccount("allowed");
/*  65 */     Account denied = createUserAccount("denied");
/*  66 */     Account noAclButHasFolderGrant = createUserAccount("noAclButHasFolderGrant");
/*  67 */     Account noAclAndNoFolderGrant = createUserAccount("noAclAndNoFolderGrant");
/*     */     
/*     */ 
/*  70 */     Account owner = createUserAccount("owner");
/*     */     
/*  72 */     ZMailbox ownerMbox = TestUtil.getZMailbox(owner.getName());
/*     */     
/*     */ 
/*  75 */     ZAce aceAllow = new ZAce(ZAce.GranteeType.usr, allowed.getId(), allowed.getName(), "invite", false, null);
/*  76 */     ownerMbox.grantRight(aceAllow);
/*  77 */     ZAce aceDeny = new ZAce(ZAce.GranteeType.usr, denied.getId(), denied.getName(), "invite", true, null);
/*  78 */     ownerMbox.grantRight(aceDeny);
/*     */     
/*     */ 
/*  81 */     String folderPath = "/Calendar";
/*  82 */     short rights = 15;
/*  83 */     String rightsStr = ACL.rightsToString(rights);
/*  84 */     ZFolder folder = ownerMbox.getFolder(folderPath);
/*  85 */     ownerMbox.modifyFolderGrant(folder.getId(), ZGrant.GranteeType.usr, denied.getName(), rightsStr, null);
/*  86 */     ownerMbox.modifyFolderGrant(folder.getId(), ZGrant.GranteeType.usr, noAclButHasFolderGrant.getName(), rightsStr, null);
/*     */     
/*     */ 
/*  89 */     List<String> rightsToCheck = new ArrayList();
/*  90 */     rightsToCheck.add("invite");
/*     */     
/*     */ 
/*  93 */     boolean result = TestUtil.getZMailbox(allowed.getName()).checkRights(owner.getName(), rightsToCheck);
/*  94 */     Assert.assertTrue(result);
/*     */     
/*  96 */     result = TestUtil.getZMailbox(denied.getName()).checkRights(owner.getName(), rightsToCheck);
/*  97 */     Assert.assertTrue(result);
/*     */     
/*  99 */     result = TestUtil.getZMailbox(noAclButHasFolderGrant.getName()).checkRights(owner.getName(), rightsToCheck);
/* 100 */     Assert.assertTrue(result);
/*     */     
/* 102 */     result = TestUtil.getZMailbox(noAclAndNoFolderGrant.getName()).checkRights(owner.getName(), rightsToCheck);
/* 103 */     Assert.assertFalse(result);
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/qa/unittest/prov/soap/TestACLUserRights.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */